import Vue from 'vue';
import VueRouter from 'vue-router';
import Login from '../views/Login.vue';
import Home from '../views/Home.vue';
import Welcome from '../views/Welcome.vue';
import DormAdminManger from '../views/DormAdminManger.vue';
import DormsManger from '../views/DormsManger.vue';
import DormsAddOrEdit from '../views/DormsAddOrEdit.vue'
import StudentsManger from '../views/StudentsManger.vue';
import DormAdminAddOrEdit from '../views/DormAdminAddOrEdit.vue';
import StudentsAddOrEdit from '../views/StudentsAddOrEdit.vue';
import AbsencesManger from '../views/AbsencesManger.vue';
import AbsencesAddOrEdit from '../views/AbsencesAddOrEdit.vue';
import ModifyPassword from '../views/ModifyPassword.vue';
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    component: Login,
  },
  {
    path: '/login',
    component: Login,
  },
  // {
  //   path: '/about',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () =>
  //     import(/* webpackChunkName: "about" */ '../views/About.vue'),
  // },
  {
    path: '/home',
    component: Home,
    redirect: '/welcome.html',
    // beforeEnter: (to, from, next) => {
    //   // ...
    // }
    children: [
      { path: '/welcome.html', Nmae: Welcome, component: Welcome },
      { path: '/dormAdmins.html', component: DormAdminManger },
      { path: '/dormAdmins/toAdd.html', component: DormAdminAddOrEdit },
      { path: '/dormAdmins/toEdit/:id.html', component: DormAdminAddOrEdit },
      { path: '/students.html', component: StudentsManger },
      { path: '/students/toAdd.html', component: StudentsAddOrEdit },
      { path: '/students/toEdit/:id.html', component: StudentsAddOrEdit },
      { path: '/dorms.html', component: DormsManger },
      { path: '/dorms/toAdd.html', component: DormsAddOrEdit },
      { path: '/dorms/toEdit/:id.html', component: DormsAddOrEdit },
      { path: '/absences.html', component:AbsencesManger },
      { path: '/absences/toAdd.html', component: AbsencesAddOrEdit },
      { path: '/absences/toEdit/:id.html', component: AbsencesAddOrEdit },
      { path: '/modifyPassword.html', component: ModifyPassword },
    ],
  },
];

const router = new VueRouter({
  routes,
});

router.beforeEach((to,from,next)=>{
  NProgress.start()
  next()
})

router.afterEach(() => {
  NProgress.done()
})
export default router;
